# @Time    :2025/3/31 16:47
"""
2)多态体现在方法的返回值位置

"""

class Bird:
    def __init__(self, name):
        self.name = name


class Fish:
    def __init__(self, name):
        self.name = name


class Dog:
    def __init__(self, name):
        self.name = name


class Person:
    def __init__(self, name, age):
        self.name = name
        self.age = age

    def cal(self, flag):
        ani = None
        match flag:
            case "1":
                ani = Bird("红火")
            case "2":
                ani = Dog("旺财")
            case "3":
                ani = Fish("小鱼儿")
        return ani  #多态体现在方法的返回值位置

    def feed(self, ani):
        print(f"{self.name}正在照顾{ani.name}")


p1 = Person("张张同学", 23)
f1 = Fish("小鱼儿")
d1 = Dog("旺财")
b1 = Bird("蝴蝶")
p1.feed(b1)
p1.feed(d1)
p1.feed(f1)
# p1.feed(ani=Dog("旺财"))
